package com.larry.mr.etl;

/**
 * @ProjectName map-reduce
 * @Author larry
 * @Date 23:10 2022/5/30
 * @Description TODO
 **/
public class ETLUtils {
    public static String etlString(String line) {

        String[] fields = line.split("\t");
        StringBuffer sb = new StringBuffer();

        if (fields.length < 9){
            return null;
        }

        fields[3] = fields[3].replace(" ","");

        for (int i = 0; i < fields.length; i++) {

            if (i < 9){
                if (i == fields.length - 1){
                    sb.append(fields[i]);
                }else {
                    sb.append(fields[i]).append("\t");
                }
            }else {
                if (i == fields.length - 1){
                    sb.append(fields[i]);
                }else {
                    sb.append(fields[i]).append("&");
                }
            }

        }

        return sb.toString();
    }
}
